package com.shen.nettysocketchat.bean

import com.shen.nettysocketchat.utils.StringUtil
import java.lang.NullPointerException

/**
 * 内容消息，包含单聊消息及群聊消息
 */
open class ContentMessage : BaseMessage {
    var isRead = false
    var isPlaying = false
    var isLoading = false

    constructor() {}
    constructor(
        msgId: String?, msgType: Int, msgContentType: Int, fromId: String?, toId: String?,
        timestamp: Long, statusReport: Int, extend: String?, content: String?
    ) {
        this.msgId = msgId
        this.msgType = msgType
        this.msgContentType = msgContentType
        this.fromId = fromId
        this.toId = toId
        this.timestamp = timestamp
        this.statusReport = statusReport
        this.extend = extend
        this.content = content
    }

    override fun equals(obj: Any?): Boolean {
        return if (obj == null || obj !is ContentMessage) {
            false
        } else StringUtil.equals(msgId, obj.msgId)
    }

    override fun hashCode(): Int {
        try {
            return msgId.hashCode()
        } catch (e: NullPointerException) {
            e.printStackTrace()
        }
        return 1
    }
}